From 9f24b54786d8371f77f9ba0c4475ed82b2e0e68f Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 31 Jul 2015 17:57:04 -0400 Subject: [PATCH] Code cleanup Use g_slist_free_full more consistently. This commit just converts the obvious cases where g_slist_forall is directly followed by g_slist_free. --- gdk/gdkdisplay.c | 4 +--- gdk/x11/gdkapplaunchcontext-x11.c | 3 +-- gdk/x11/gdkdisplay-x11.c | 3 +-- gtk/deprecated/gtkrc.c | 7 ++----- gtk/deprecated/gtkstyle.c | 6 ++---- gtk/gtkaboutdialog.c | 10 +++------- gtk/gtkbookmarksmanager.c | 14 +++++--------- gtk/gtkbuilder.c | 6 ++---- gtk/gtkbuilderparser.c | 13 ++++--------- gtk/gtkcellarea.c | 7 ++----- gtk/gtkcellareabox.c | 15 +++++++-------- gtk/gtkfilechooser.c | 15 +++++---------- gtk/gtkfilechooserbutton.c | 11 ++++------- gtk/gtkfilechooserdialog.c | 3 +-- gtk/gtkfilechooserwidget.c | 9 +++------ gtk/gtkfilefilter.c | 3 +-- gtk/gtkfilesystem.c | 6 ++---- gtk/gtkimcontextsimple.c | 9 ++------- gtk/gtkimmodule.c | 9 +-------- gtk/gtkplacessidebar.c | 3 +-- gtk/gtkrecentchooserdefault.c | 3 +-- gtk/gtkrecentmanager.c | 12 ++---------- gtk/gtktextbuffer.c | 4 +--- gtk/gtktextchild.c | 12 ++---------- gtk/gtkwidget.c | 3 +-- 25 files changed, 57 insertions(+), 133 deletions(-) diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c index 79fc2d8a69..892d6a73f9 100644 --- a/gdk/gdkdisplay.c +++ b/gdk/gdkdisplay.c @@ -2192,9 +2192,7 @@ gdk_error_trap_push (void) g_slist_foreach (trap->displays, (GFunc) g_object_ref, NULL); for (l = trap->displays; l != NULL; l = l->next) - { - class->push_error_trap (l->data); - } + class->push_error_trap (l->data); g_queue_push_head (&gdk_error_traps, trap); } diff --git a/gdk/x11/gdkapplaunchcontext-x11.c b/gdk/x11/gdkapplaunchcontext-x11.c index 7713922a0b..6e816e4089 100644 --- a/gdk/x11/gdkapplaunchcontext-x11.c +++ b/gdk/x11/gdkapplaunchcontext-x11.c @@ -159,8 +159,7 @@ free_startup_timeout (void *data) std = data; - g_slist_foreach (std->contexts, (GFunc) free_startup_notification_data, NULL); - g_slist_free (std->contexts); + g_slist_free_full (std->contexts, free_startup_notification_data); if (std->timeout_id != 0) { diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index 9bb27eecfb..0030c6c116 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -1948,8 +1948,7 @@ gdk_x11_display_finalize (GObject *object) XDestroyWindow (display_x11->xdisplay, display_x11->leader_window); /* List of event window extraction functions */ - g_slist_foreach (display_x11->event_types, (GFunc)g_free, NULL); - g_slist_free (display_x11->event_types); + g_slist_free_full (display_x11->event_types, g_free); /* input GdkDevice list */ g_list_free_full (display_x11->input_devices, g_object_unref); diff --git a/gtk/deprecated/gtkrc.c b/gtk/deprecated/gtkrc.c index c461399274..93fa01dee3 100644 --- a/gtk/deprecated/gtkrc.c +++ b/gtk/deprecated/gtkrc.c @@ -1018,11 +1018,8 @@ gtk_rc_style_finalize (GObject *object) rc_style->rc_properties = NULL; } - g_slist_foreach (rc_style->icon_factories, (GFunc) g_object_unref, NULL); - g_slist_free (rc_style->icon_factories); - - g_slist_foreach (rc_priv->color_hashes, (GFunc) g_hash_table_unref, NULL); - g_slist_free (rc_priv->color_hashes); + g_slist_free_full (rc_style->icon_factories, g_object_unref); + g_slist_free_full (rc_priv->color_hashes, (GDestroyNotify)g_hash_table_unref); G_OBJECT_CLASS (gtk_rc_style_parent_class)->finalize (object); } diff --git a/gtk/deprecated/gtkstyle.c b/gtk/deprecated/gtkstyle.c index c271982e1a..a2405a113a 100644 --- a/gtk/deprecated/gtkstyle.c +++ b/gtk/deprecated/gtkstyle.c @@ -542,8 +542,7 @@ gtk_style_finalize (GObject *object) } } - g_slist_foreach (style->icon_factories, (GFunc) g_object_unref, NULL); - g_slist_free (style->icon_factories); + g_slist_free_full (style->icon_factories, g_object_unref); pango_font_description_free (style->font_desc); @@ -1108,8 +1107,7 @@ gtk_style_real_copy (GtkStyle *style, if (src->rc_style) g_object_ref (src->rc_style); - g_slist_foreach (style->icon_factories, (GFunc) g_object_unref, NULL); - g_slist_free (style->icon_factories); + g_slist_free_full (style->icon_factories, g_object_unref); style->icon_factories = g_slist_copy (src->icon_factories); g_slist_foreach (style->icon_factories, (GFunc) g_object_ref, NULL); } diff --git a/gtk/gtkaboutdialog.c b/gtk/gtkaboutdialog.c index e7537a4efc..0a827318cf 100644 --- a/gtk/gtkaboutdialog.c +++ b/gtk/gtkaboutdialog.c @@ -787,9 +787,7 @@ gtk_about_dialog_finalize (GObject *object) g_strfreev (priv->artists); g_slist_free_full (priv->credit_sections, destroy_credit_section); - - g_slist_foreach (priv->visited_links, (GFunc)g_free, NULL); - g_slist_free (priv->visited_links); + g_slist_free_full (priv->visited_links, g_free); G_OBJECT_CLASS (gtk_about_dialog_parent_class)->finalize (object); } @@ -1931,8 +1929,7 @@ follow_if_link (GtkAboutDialog *about, } } - if (tags) - g_slist_free (tags); + g_slist_free (tags); } static gboolean @@ -2034,8 +2031,7 @@ set_cursor_if_appropriate (GtkAboutDialog *about, gdk_window_set_device_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), device, priv->regular_cursor); } - if (tags) - g_slist_free (tags); + g_slist_free (tags); } static gboolean diff --git a/gtk/gtkbookmarksmanager.c b/gtk/gtkbookmarksmanager.c index 968b49c525..7523aed0bb 100644 --- a/gtk/gtkbookmarksmanager.c +++ b/gtk/gtkbookmarksmanager.c @@ -31,8 +31,10 @@ #include "gtkfilechooser.h" /* for the GError types */ static void -_gtk_bookmark_free (GtkBookmark *bookmark) +_gtk_bookmark_free (gpointer data) { + GtkBookmark *bookmark = data; + g_object_unref (bookmark->file); g_free (bookmark->label); g_slice_free (GtkBookmark, bookmark); @@ -197,9 +199,7 @@ bookmarks_file_changed (GFileMonitor *monitor, case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: case G_FILE_MONITOR_EVENT_CREATED: case G_FILE_MONITOR_EVENT_DELETED: - g_slist_foreach (manager->bookmarks, (GFunc) _gtk_bookmark_free, NULL); - g_slist_free (manager->bookmarks); - + g_slist_free_full (manager->bookmarks, _gtk_bookmark_free); manager->bookmarks = read_bookmarks (file); gdk_threads_enter (); @@ -271,11 +271,7 @@ _gtk_bookmarks_manager_free (GtkBookmarksManager *manager) g_object_unref (manager->bookmarks_monitor); } - if (manager->bookmarks) - { - g_slist_foreach (manager->bookmarks, (GFunc) _gtk_bookmark_free, NULL); - g_slist_free (manager->bookmarks); - } + g_slist_free_full (manager->bookmarks, _gtk_bookmark_free); g_free (manager); } diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c index 806fc12543..32bfe1764c 100644 --- a/gtk/gtkbuilder.c +++ b/gtk/gtkbuilder.c @@ -319,8 +319,7 @@ gtk_builder_finalize (GObject *object) if (priv->callbacks) g_hash_table_destroy (priv->callbacks); - g_slist_foreach (priv->signals, (GFunc) _free_signal_info, NULL); - g_slist_free (priv->signals); + g_slist_free_full (priv->signals, (GDestroyNotify)_free_signal_info); G_OBJECT_CLASS (gtk_builder_parent_class)->finalize (object); } @@ -1734,8 +1733,7 @@ gtk_builder_connect_signals_full (GtkBuilder *builder, connect_object, signal->flags, user_data); } - g_slist_foreach (builder->priv->signals, (GFunc)_free_signal_info, NULL); - g_slist_free (builder->priv->signals); + g_slist_free_full (builder->priv->signals, (GDestroyNotify)_free_signal_info); builder->priv->signals = NULL; if (detailed_id) diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c index 9153f1515c..decbdb07e9 100644 --- a/gtk/gtkbuilderparser.c +++ b/gtk/gtkbuilderparser.c @@ -512,9 +512,7 @@ free_object_info (ObjectInfo *info) { /* Do not free the signal items, which GtkBuilder takes ownership of */ g_slist_free (info->signals); - g_slist_foreach (info->properties, - (GFunc)free_property_info, NULL); - g_slist_free (info->properties); + g_slist_free_full (info->properties, (GDestroyNotify)free_property_info); g_free (info->constructor); g_free (info->id); g_slice_free (ObjectInfo, info); @@ -1343,13 +1341,10 @@ _gtk_builder_parser_parse_buffer (GtkBuilder *builder, out: - g_slist_foreach (data->stack, (GFunc)free_info, NULL); - g_slist_free (data->stack); - g_slist_foreach (data->custom_finalizers, (GFunc)free_subparser, NULL); - g_slist_free (data->custom_finalizers); + g_slist_free_full (data->stack, (GDestroyNotify)free_info); + g_slist_free_full (data->custom_finalizers, (GDestroyNotify)free_subparser); g_slist_free (data->finalizers); - g_slist_foreach (data->requested_objects, (GFunc) g_free, NULL); - g_slist_free (data->requested_objects); + g_slist_free_full (data->requested_objects, g_free); g_free (data->domain); g_hash_table_destroy (data->object_ids); g_markup_parse_context_free (data->ctx); diff --git a/gtk/gtkcellarea.c b/gtk/gtkcellarea.c index 1ce312abf3..6d85040b09 100644 --- a/gtk/gtkcellarea.c +++ b/gtk/gtkcellarea.c @@ -858,8 +858,7 @@ cell_info_free (CellInfo *info) if (info->destroy) info->destroy (info->data); - g_slist_foreach (info->attributes, (GFunc)cell_attribute_free, NULL); - g_slist_free (info->attributes); + g_slist_free_full (info->attributes, (GDestroyNotify)cell_attribute_free); g_slice_free (CellInfo, info); } @@ -1540,9 +1539,7 @@ gtk_cell_area_clear_attributes (GtkCellLayout *cell_layout, if (info) { - g_slist_foreach (info->attributes, (GFunc)cell_attribute_free, NULL); - g_slist_free (info->attributes); - + g_slist_free_full (info->attributes, (GDestroyNotify)cell_attribute_free); info->attributes = NULL; } } diff --git a/gtk/gtkcellareabox.c b/gtk/gtkcellareabox.c index f0a72bc2ef..7ea9851db4 100644 --- a/gtk/gtkcellareabox.c +++ b/gtk/gtkcellareabox.c @@ -1292,16 +1292,15 @@ gtk_cell_area_box_foreach_alloc (GtkCellArea *area, break; } - g_slist_foreach (allocated_cells, (GFunc)allocated_cell_free, NULL); - g_slist_free (allocated_cells); + g_slist_free_full (allocated_cells, (GDestroyNotify)allocated_cell_free); } static void -gtk_cell_area_box_apply_attributes (GtkCellArea *area, - GtkTreeModel *tree_model, - GtkTreeIter *iter, - gboolean is_expander, - gboolean is_expanded) +gtk_cell_area_box_apply_attributes (GtkCellArea *area, + GtkTreeModel *tree_model, + GtkTreeIter *iter, + gboolean is_expander, + gboolean is_expanded) { GtkCellAreaBox *box = GTK_CELL_AREA_BOX (area); GtkCellAreaBoxPrivate *priv = box->priv; @@ -1309,7 +1308,7 @@ gtk_cell_area_box_apply_attributes (GtkCellArea *area, /* Call the parent class to apply the attributes */ GTK_CELL_AREA_CLASS - (gtk_cell_area_box_parent_class)->apply_attributes (area, tree_model, iter, + (gtk_cell_area_box_parent_class)->apply_attributes (area, tree_model, iter, is_expander, is_expanded); /* Update visible state for cell groups */ diff --git a/gtk/gtkfilechooser.c b/gtk/gtkfilechooser.c index 969eae257a..b8513cebb4 100644 --- a/gtk/gtkfilechooser.c +++ b/gtk/gtkfilechooser.c @@ -873,8 +873,7 @@ gtk_file_chooser_get_filenames (GtkFileChooser *chooser) files = gtk_file_chooser_get_files (chooser); result = files_to_strings (files, g_file_get_path); - g_slist_foreach (files, (GFunc) g_object_unref, NULL); - g_slist_free (files); + g_slist_free_full (files, g_object_unref); return result; } @@ -1218,8 +1217,7 @@ gtk_file_chooser_get_uris (GtkFileChooser *chooser) else result = files_to_strings (files, g_file_get_uri); - g_slist_foreach (files, (GFunc) g_object_unref, NULL); - g_slist_free (files); + g_slist_free_full (files, g_object_unref); return result; } @@ -1498,8 +1496,7 @@ gtk_file_chooser_get_file (GtkFileChooser *chooser) result = list->data; list = g_slist_delete_link (list, list); - g_slist_foreach (list, (GFunc) g_object_unref, NULL); - g_slist_free (list); + g_slist_free_full (list, g_object_unref); } return result; @@ -2064,8 +2061,7 @@ gtk_file_chooser_list_shortcut_folders (GtkFileChooser *chooser) folders = _gtk_file_chooser_list_shortcut_folder_files (chooser); result = files_to_strings (folders, g_file_get_path); - g_slist_foreach (folders, (GFunc) g_object_unref, NULL); - g_slist_free (folders); + g_slist_free_full (folders, g_object_unref); return result; } @@ -2161,8 +2157,7 @@ gtk_file_chooser_list_shortcut_folder_uris (GtkFileChooser *chooser) folders = _gtk_file_chooser_list_shortcut_folder_files (chooser); result = files_to_strings (folders, g_file_get_uri); - g_slist_foreach (folders, (GFunc) g_object_unref, NULL); - g_slist_free (folders); + g_slist_free_full (folders, g_object_unref); return result; } diff --git a/gtk/gtkfilechooserbutton.c b/gtk/gtkfilechooserbutton.c index ad3d136bed..a7fb92309e 100644 --- a/gtk/gtkfilechooserbutton.c +++ b/gtk/gtkfilechooserbutton.c @@ -839,8 +839,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS list = _gtk_bookmarks_manager_list_bookmarks (priv->bookmarks_manager); model_add_bookmarks (button, list); - g_slist_foreach (list, (GFunc) g_object_unref, NULL); - g_slist_free (list); + g_slist_free_full (list, g_object_unref); model_add_other (button); @@ -2625,14 +2624,12 @@ bookmarks_changed_cb (gpointer user_data) bookmarks = _gtk_bookmarks_manager_list_bookmarks (priv->bookmarks_manager); model_remove_rows (user_data, - model_get_type_position (user_data, - ROW_TYPE_BOOKMARK_SEPARATOR), - (priv->n_bookmarks + priv->has_bookmark_separator)); + model_get_type_position (user_data, ROW_TYPE_BOOKMARK_SEPARATOR), + priv->n_bookmarks + priv->has_bookmark_separator); priv->has_bookmark_separator = FALSE; priv->n_bookmarks = 0; model_add_bookmarks (user_data, bookmarks); - g_slist_foreach (bookmarks, (GFunc) g_object_unref, NULL); - g_slist_free (bookmarks); + g_slist_free_full (bookmarks, g_object_unref); gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (priv->filter_model)); diff --git a/gtk/gtkfilechooserdialog.c b/gtk/gtkfilechooserdialog.c index 66ed07123c..3f3cf507f8 100644 --- a/gtk/gtkfilechooserdialog.c +++ b/gtk/gtkfilechooserdialog.c @@ -424,8 +424,7 @@ file_chooser_widget_selection_changed (GtkWidget *widget, sensitive = (uris != NULL); gtk_widget_set_sensitive (button, sensitive); - if (uris) - g_slist_free_full (uris, g_free); + g_slist_free_full (uris, g_free); } static void diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index 47f595f0e5..84dc970833 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -1744,8 +1744,7 @@ visit_file_cb (GSimpleAction *action, gtk_file_chooser_widget_select_file (GTK_FILE_CHOOSER (impl), file, NULL); /* NULL-GError */ } - g_slist_foreach (files, (GFunc) g_object_unref, NULL); - g_slist_free (files); + g_slist_free_full (files, g_object_unref); } /* Callback used when the "Open this folder" menu item is activated */ @@ -1770,8 +1769,7 @@ open_folder_cb (GSimpleAction *action, g_free (uri); } - g_slist_foreach (files, (GFunc) g_object_unref, NULL); - g_slist_free (files); + g_slist_free_full (files, g_object_unref); } /* callback used when the "Show Hidden Files" menu item is toggled */ @@ -6694,8 +6692,7 @@ add_selection_to_recent_list (GtkFileChooserWidget *impl) } } - g_slist_foreach (files, (GFunc) g_object_unref, NULL); - g_slist_free (files); + g_slist_free_full (files, g_object_unref); } static gboolean diff --git a/gtk/gtkfilefilter.c b/gtk/gtkfilefilter.c index 06edae1a84..46b1459388 100644 --- a/gtk/gtkfilefilter.c +++ b/gtk/gtkfilefilter.c @@ -187,8 +187,7 @@ gtk_file_filter_finalize (GObject *object) { GtkFileFilter *filter = GTK_FILE_FILTER (object); - g_slist_foreach (filter->rules, (GFunc)filter_rule_free, NULL); - g_slist_free (filter->rules); + g_slist_free_full (filter->rules, (GDestroyNotify)filter_rule_free); g_free (filter->name); diff --git a/gtk/gtkfilesystem.c b/gtk/gtkfilesystem.c index baae74251d..17213e15c7 100644 --- a/gtk/gtkfilesystem.c +++ b/gtk/gtkfilesystem.c @@ -120,8 +120,7 @@ gtk_file_system_dispose (GObject *object) if (priv->volumes) { - g_slist_foreach (priv->volumes, (GFunc) g_object_unref, NULL); - g_slist_free (priv->volumes); + g_slist_free_full (priv->volumes, g_object_unref); priv->volumes = NULL; } @@ -199,8 +198,7 @@ get_volumes_list (GtkFileSystem *file_system) if (priv->volumes) { - g_slist_foreach (priv->volumes, (GFunc) g_object_unref, NULL); - g_slist_free (priv->volumes); + g_slist_free_full (priv->volumes, g_object_unref); priv->volumes = NULL; } diff --git a/gtk/gtkimcontextsimple.c b/gtk/gtkimcontextsimple.c index 8ddbdc42a9..c6ac597eee 100644 --- a/gtk/gtkimcontextsimple.c +++ b/gtk/gtkimcontextsimple.c @@ -138,13 +138,8 @@ gtk_im_context_simple_finalize (GObject *obj) GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (obj); GtkIMContextSimplePrivate *priv = context_simple->priv; - if (priv->tables) - { - g_slist_foreach (priv->tables, (GFunc)g_free, NULL); - g_slist_free (priv->tables); - - priv->tables = NULL; - } + g_slist_free_full (priv->tables, g_free); + priv->tables = NULL; G_OBJECT_CLASS (gtk_im_context_simple_parent_class)->finalize (obj); } diff --git a/gtk/gtkimmodule.c b/gtk/gtkimmodule.c index 51044ebcb4..35398fe733 100644 --- a/gtk/gtkimmodule.c +++ b/gtk/gtkimmodule.c @@ -490,14 +490,7 @@ G_GNUC_END_IGNORE_DEPRECATIONS if (have_error) { - GSList *tmp_list = infos; - while (tmp_list) - { - free_info (tmp_list->data); - tmp_list = tmp_list->next; - } - g_slist_free (infos); - + g_slist_free_full (infos, (GDestroyNotify)free_info); g_object_unref (module); } else if (module) diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c index e86dd4ddba..1f00bda337 100644 --- a/gtk/gtkplacessidebar.c +++ b/gtk/gtkplacessidebar.c @@ -1220,8 +1220,7 @@ update_places (GtkPlacesSidebar *sidebar) clos); } - g_slist_foreach (bookmarks, (GFunc) g_object_unref, NULL); - g_slist_free (bookmarks); + g_slist_free_full (bookmarks, g_object_unref); /* Add new bookmark row */ new_bookmark_icon = g_themed_icon_new ("bookmark-new-symbolic"); diff --git a/gtk/gtkrecentchooserdefault.c b/gtk/gtkrecentchooserdefault.c index 5882dd858a..f6b0b87f67 100644 --- a/gtk/gtkrecentchooserdefault.c +++ b/gtk/gtkrecentchooserdefault.c @@ -591,8 +591,7 @@ gtk_recent_chooser_default_dispose (GObject *object) if (impl->priv->filters) { - g_slist_foreach (impl->priv->filters, (GFunc) g_object_unref, NULL); - g_slist_free (impl->priv->filters); + g_slist_free_full (impl->priv->filters, g_object_unref); impl->priv->filters = NULL; } diff --git a/gtk/gtkrecentmanager.c b/gtk/gtkrecentmanager.c index 471f6d8be8..ce749908a5 100644 --- a/gtk/gtkrecentmanager.c +++ b/gtk/gtkrecentmanager.c @@ -1497,11 +1497,7 @@ gtk_recent_info_free (GtkRecentInfo *recent_info) if (recent_info->applications) { - g_slist_foreach (recent_info->applications, - (GFunc) recent_app_info_free, - NULL); - g_slist_free (recent_info->applications); - + g_slist_free_full (recent_info->applications, (GDestroyNotify)recent_app_info_free); recent_info->applications = NULL; } @@ -1510,11 +1506,7 @@ gtk_recent_info_free (GtkRecentInfo *recent_info) if (recent_info->groups) { - g_slist_foreach (recent_info->groups, - (GFunc) g_free, - NULL); - g_slist_free (recent_info->groups); - + g_slist_free_full (recent_info->groups, g_free); recent_info->groups = NULL; } diff --git a/gtk/gtktextbuffer.c b/gtk/gtktextbuffer.c index 8e3e1de04e..9f5f04d4d0 100644 --- a/gtk/gtktextbuffer.c +++ b/gtk/gtktextbuffer.c @@ -2848,9 +2848,7 @@ gtk_text_buffer_remove_all_tags (GtkTextBuffer *buffer, tmp_list = tmp_list->next; } - g_slist_foreach (tags, (GFunc) g_object_unref, NULL); - - g_slist_free (tags); + g_slist_free_full (tags, g_object_unref); } diff --git a/gtk/gtktextchild.c b/gtk/gtktextchild.c index 61a2bfbc4a..3c075ead08 100644 --- a/gtk/gtktextchild.c +++ b/gtk/gtktextchild.c @@ -345,7 +345,6 @@ static void gtk_text_child_anchor_finalize (GObject *obj) { GtkTextChildAnchor *anchor; - GSList *tmp_list; GtkTextLineSegment *seg; anchor = GTK_TEXT_CHILD_ANCHOR (obj); @@ -361,15 +360,8 @@ gtk_text_child_anchor_finalize (GObject *obj) "and the refcount is 0."); return; } - - tmp_list = seg->body.child.widgets; - while (tmp_list) - { - g_object_unref (tmp_list->data); - tmp_list = g_slist_next (tmp_list); - } - - g_slist_free (seg->body.child.widgets); + + g_slist_free_full (seg->body.child.widgets, g_object_unref); g_slice_free1 (WIDGET_SEG_SIZE, seg); } diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 6609ec246d..37348ad8d1 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -15516,8 +15516,7 @@ static gboolean tooltip_query_idle (gpointer data) { g_slist_foreach (tooltip_query_displays, (GFunc)gtk_tooltip_trigger_tooltip_query, NULL); - g_slist_foreach (tooltip_query_displays, (GFunc)g_object_unref, NULL); - g_slist_free (tooltip_query_displays); + g_slist_free_full (tooltip_query_displays, g_object_unref); tooltip_query_displays = NULL; tooltip_query_id = 0; -- 2.30.2